home *** CD-ROM | disk | FTP | other *** search
/ PC User 2004 August / Disc 1 / PCU0804CD1.iso / software / browsers / files / opera1.exe / OPERA.JAR / com / opera / JavaConsole.class (.txt) < prev    next >
Encoding:
Java Class File  |  2004-02-12  |  4.0 KB  |  141 lines

  1. package com.opera;
  2.  
  3. import java.awt.Button;
  4. import java.awt.Frame;
  5. import java.awt.TextArea;
  6. import java.awt.event.ActionEvent;
  7. import java.awt.event.ActionListener;
  8. import java.awt.event.KeyEvent;
  9. import java.awt.event.KeyListener;
  10. import java.awt.event.WindowEvent;
  11. import java.awt.event.WindowListener;
  12.  
  13. public class JavaConsole extends Frame implements WindowListener, ActionListener, KeyListener {
  14.    private TextArea output_area = new TextArea();
  15.    private Button but;
  16.  
  17.    public JavaConsole() {
  18.       super("Opera Java console");
  19.       this.add(this.output_area);
  20.       this.but = new Button("Clear");
  21.       this.but.addActionListener(this);
  22.       this.add("South", this.but);
  23.       this.pack();
  24.       this.output_area.setVisible(true);
  25.       this.output_area.setEditable(false);
  26.       this.setSize(300, 250);
  27.       ConsoleOStream var1 = new ConsoleOStream(this.output_area);
  28.       System.setOut(var1);
  29.       System.setErr(var1);
  30.       this.addWindowListener(this);
  31.       this.output_area.addKeyListener(this);
  32.       this.but.addKeyListener(this);
  33.       this.printInfo();
  34.    }
  35.  
  36.    public void keyTyped(KeyEvent var1) {
  37.    }
  38.  
  39.    public void keyPressed(KeyEvent var1) {
  40.       if (var1.getModifiers() == 0) {
  41.          switch (var1.getKeyCode()) {
  42.             case 67:
  43.                this.output_area.setText((String)null);
  44.                this.printInfo();
  45.             case 68:
  46.             case 69:
  47.             case 73:
  48.             case 74:
  49.             case 75:
  50.             case 78:
  51.             case 79:
  52.             case 80:
  53.             case 81:
  54.             case 82:
  55.             case 83:
  56.             case 84:
  57.             case 85:
  58.             case 86:
  59.             case 87:
  60.             default:
  61.                break;
  62.             case 70:
  63.                System.out.print("Running finalization ... ");
  64.                System.runFinalization();
  65.                System.out.println("finished.");
  66.                break;
  67.             case 71:
  68.                System.out.print("Running garbage collection ... ");
  69.                System.gc();
  70.                System.out.println("finished.");
  71.                break;
  72.             case 72:
  73.                this.printHelp();
  74.                break;
  75.             case 76:
  76.                PluginPanel.printClassLoaders();
  77.                break;
  78.             case 77:
  79.                long var2 = Runtime.getRuntime().freeMemory() / 1024L;
  80.                long var4 = Runtime.getRuntime().totalMemory() / 1024L;
  81.                System.out.println("Total memory: " + var4 + "K  Free memory: " + var2 + "K");
  82.                break;
  83.             case 88:
  84.                PluginPanel.clearClassLoaderCache();
  85.          }
  86.  
  87.       }
  88.    }
  89.  
  90.    private void printInfo() {
  91.       System.out.println("-- Opera Java Console --\n");
  92.       System.out.println("Java vendor: " + System.getProperty("java.vendor"));
  93.       System.out.println("Java version: " + System.getProperty("java.version"));
  94.       System.out.println("\ntype 'h' for help\n\n--");
  95.    }
  96.  
  97.    private void printHelp() {
  98.       System.out.println("\nCommands:\n----------------------------------------");
  99.       System.out.println("c - clear console");
  100.       System.out.println("f - run finalization");
  101.       System.out.println("g - run garbage collection");
  102.       System.out.println("h - help");
  103.       System.out.println("l - list cached classloaders");
  104.       System.out.println("m - memory usage");
  105.       System.out.println("x - clear classloader cache\n");
  106.    }
  107.  
  108.    public void keyReleased(KeyEvent var1) {
  109.    }
  110.  
  111.    public void windowActivated(WindowEvent var1) {
  112.    }
  113.  
  114.    public void windowClosed(WindowEvent var1) {
  115.    }
  116.  
  117.    public void windowClosing(WindowEvent var1) {
  118.       this.dispose();
  119.    }
  120.  
  121.    public void windowDeactivated(WindowEvent var1) {
  122.    }
  123.  
  124.    public void windowDeiconified(WindowEvent var1) {
  125.    }
  126.  
  127.    public void windowIconified(WindowEvent var1) {
  128.    }
  129.  
  130.    public void windowOpened(WindowEvent var1) {
  131.    }
  132.  
  133.    public void actionPerformed(ActionEvent var1) {
  134.       if (var1.getSource() == this.but) {
  135.          this.output_area.setText((String)null);
  136.          this.printInfo();
  137.       }
  138.  
  139.    }
  140. }
  141.